/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.finder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import ru.jSky.interfaces.JSkyMod;
import ru.jSky.interfaces.Major;
import skyproc.GRUP_TYPE;

/**
 *
 * @author Rakev
 */
public class FromModByEdidFinder<E extends Major> implements FinderByEdid<E> {

    private JSkyMod mod;
    private GRUP_TYPE[] lookingGrups;

    public FromModByEdidFinder(JSkyMod mod, GRUP_TYPE... lookingGrups) {
        this.mod = mod;
        this.lookingGrups = lookingGrups;
    }

    @Override
    public E find(String edId) {
        return (E) mod.getMajor(edId, lookingGrups);
    }

    @Override
    public Collection<E> findMany(String... edIds) {
        List<E> result = new ArrayList<>(edIds.length);
        for (String edid : edIds) {
            result.add(find(edid));
        }
        return result;
    }

    @Override
    public Collection<E> find(Collection<String> edIds) {
        List<E> result = new ArrayList<>(edIds.size());
        for (String edid : edIds) {
            result.add(find(edid));
        }
        return result;
    }
}
